<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
    <style>
      #progress {
        position: relative;
        width: 100%;
        height: 6px;
        border-radius: 3px;
        background: #eee;
        overflow: hidden;
      }
      #status {
        position: absolute;
        top: 0;
        right: 0;
        bottom: 0;
        left: 0;
        background: deepskyblue;
      }
    </style>
  </head>
  <body>
    <div id="progress">
      <div id="status" style="width: 0"></div>
    </div>

    <script>
      let requestId
      const bar = document.getElementById('status')
      function updateProgress(t) {
        bar.style.width = Math.min(t / 50, 100) + '%'
        if (bar.style.width != '100%') {
          requestId = requestAnimationFrame(updateProgress)
        } else {
          cancelAnimationFrame(requestId)
        }
      }
      requestId = requestAnimationFrame(updateProgress)
    </script>
  </body>
</html>
